﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data.SqlClient;
using System.Configuration;
using System.Data;
using AutoPartsSearch.Domain.Abstract;

namespace AutoPartsSearch.Domain.Common
{
    public class DbContext : IDbContext
    {
        private readonly string _connectionString;

        public IDbConnection Connection
        {
            get
            {
                var connection = new SqlConnection(this._connectionString);
                connection.Open();
                return connection;
            }
        }

        public DbContext()
        {
            this._connectionString = ConfigurationManager.ConnectionStrings["AutoPartsDB"].ConnectionString;
        }

        public DbContext(string connectionString)
        {
            this._connectionString = connectionString;
        }

    }
}
